#ifndef __COMN_STRING_API_H_
#define __COMN_STRING_API_H_

#include <typedef.h>
#include <stdarg.h>

/**
 * @brief compare string with in a limited range
 * 
 * @param s1 string 1
 * @param s2 string 2
 * @param n  maximum compare length
 * @return int zero if same otherwise nonzero
 */
int strncmp(const char *s1, const char *s2, int n);

/**
 * @brief copy source string to destination with in a limited range
 *
 * @param dst the address to save the string
 * @param src source string
 * @param n maximum copy length
 * @return int the copied length
 */
int strncpy(char *dst, const char *src, int n);

/**
 * @brief caculate the string length within a limited range
 *
 * @param src source string
 * @param n maximum copy length
 * @return int the string length
 */
int strnlen(char *src, int n);

/**
 * @brief variable string numbered printf
 *
 * @param buffer the buffer to save formatted string
 * @param length the maximum length can be saved to the buffer
 * @param fmt format control string
 * @param args the arguments list will be outputted 
 * @return int the actual outputted length
 */
int vsnprintf(char * buffer, int length, const char *fmt, va_list args);



/**
 * @brief string numbered printf
 *
 * @param buffer the buffer to save formatted string
 * @param length the maximum length can be saved to the buffer
 * @param fmt format control string
 * @param args the arguments list will be outputted 
 * @return int the actual outputted length
 */
int snprintf(char* buffer, int length, const char *fmt, ...) __CHECK_FORMAT_STR__(3, 4);

/**
 * @brief append the string length within a limited range
 *
 * @param dst the address to save the string
 * @param src source string
 * @param n maximum copy length
 * @return int the string length
 */
int strncat(char *dst, const char *src, int n);
#endif//__COMN_STRING_API_H_